package lesson8;

public class AlgorithmsComplexity {

		public static void main(String[] args) {
			
			int[] array = new int[2];
			
			//O(logN) example, where N = array.length!!!
			for(int i = 1; i < array.length; i *= 2)//logN
			{
				//do something
				System.out.println(array[i]);
			}
			
			//O(N) example, where N = array.length!!!
			for(int i = 1; i < array.length; i ++)
			{
				//do something
				System.out.println(array[i]);
			}
			
			//O(1)
			for(int i = 0; i < array.length; i ++)
			{
				if(i == 2)
					break;
			}
			
			int[] first = new int[6];
			int[] second = new int[8];
			
			//O(N*M)
			for(int i = 0; i < first.length; i ++)
			{
				for(int j = 0; j < second.length; j ++)
				{
					//do Something
					System.out.println();
				}
			}
			
			//O(N^3)
			//length = 3;
			for(int i = 0; i < array.length; i++)
			{
				for(int j = 0; j < array.length; j++)
				{
					for(int k = 0; k < array.length; k++)
					{
						//do Something
						int[] arrrrr = new int[3];
					}
				}
			}
			
			int n = 10;
			int re = 3;
			//O (1) - one variable in stack all the time
			for(int i = 0; i < n; i++)
			{
				 re = 3;
			}
			
			re = 5;
			
			//O (N) - n possible objects in heap until end of execution
			for(int i = 0; i < n; i++)
			{
				double[] xx = new double[4];
			}
			
		}
}
